var koa = require('koa');
var cors = require('koa-cors');
var koaRouter = require('koa-router');

var app = new koa();
var router = new koaRouter();

router.get('/vote/app/vote/videoList', function *(next) {
    this.body = {
	  "resultCode": "0",
	  "resultMessage": "success",
	  "resultData": {
	    "activityName": "视频投票",
	    "startDate": "2018-08-01",
	    "endDate": "2018-08-31",
	    "videoList": [
	      {
	        "videoId": "c1c1187b68764fa89eabf1d37542c868",
	        "videoName": "微视频1",
	        "videoImg": "http://www.4fz3.com//vote/userfiles/1/files/video/2018/08/img_1.jpg",
	        "voteNum": "1"
	      },
	      {
	        "videoId": "24f1e71b43ae49cebb8104601134b0d6",
	        "videoName": "微视频2",
	        "videoImg": "http://www.4fz3.com//vote/userfiles/1/files/video/2018/08/img_2.jpg",
	        "voteNum": "0"
	      },
	      {
	        "videoId": "884f69acc1d94b8c9b0d87f9d76ef899",
	        "videoName": "微视频3",
	        "videoImg": "http://www.4fz3.com//vote/userfiles/1/files/video/2018/08/img_3.jpg",
	        "voteNum": "0"
	      },
	      {
	        "videoId": "d9603f02c5654c14af8c339dd94fbb4d",
	        "videoName": "微视频4",
	        "videoImg": "http://www.4fz3.com//vote/userfiles/1/files/video/2018/08/img_1.jpg",
	        "voteNum": "0"
	      }
	    ]
	  }
	}
});

router.get('/vote/app/vote/videoDetail', function *(next) {
    this.body = {
	  "resultCode": "0",
	  "resultMessage": "success",
	  "resultData": {
	    "videoId": "c1c1187b68764fa89eabf1d37542c868",
	    "videoName": "微视频1",
	    "videoImg": "http://www.4fz3.com//vote/userfiles/1/files/video/2018/08/img_1.jpg",
	    "videoUrl": "http://www.baidu.com",
	    "videoDesc": "打了卡和访客双方都可说服力施蒂利克花历史四方达是否四大 是的",
	    "voteNum": "1",
	    "ranking": "1"
	  }
	}
});

router.get('/vote/app/sys/verificationCode', function *(next) {
    this.body = {
	  "resultCode": "0",
	  "resultMessage": "success",
	  "resultData": {
	    "code": "/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQg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gg4AwcdqB4b+3O0+t3LXcr4/dRZiijAOQBtwWxluSeQx4qdmK7W7CDxHFDCsd1cQXl+4DCDTY2kA45UHJ3YwxydvHYU2C91m5G+10drcyqP3l5ckqhBJP7vr1LAEYyNvYADbt7S2s0ZLa3igVm3MsSBQTgDJx3wB+VTUtBc25yOp3utWMiNdSaTDI4Ox0E24469B9OtRW3iTXL8+Va2sDydC0cbYHock4H41101rb3BUzwRS7em9A2PzqRVVFCqoVRwABgCq5l2GpxS2OPttF1HTmlafTLfVPPIP+vClCM5JLDvnt6VqjxJb2wCX9ld2CqNpeSImPcP4VK5z3wfQVuUUm77ic77mak9neuiWuoRPdKpxIjKzMBjdkDqMsuccAkdK5i4027g1hbiOMArJhkUHgE8DryCpx1GSDwK6eTQrEsWt0ezcjaWtW8vI+g4/HrwKzLy31WIg3NpHqQjVlS6gxHMinBYFOjZwPlU87RnnFVFq5UJ2ehoQykuAU3uMYRuAwHTGf4h6nGe/I4KwNPvvOu5UghPmxDzJz5WxmkGB905JcBeRz0XGTyCk7FOm3sjswoUYUADOeKzNKlkk1HXFeR2WO9VUDHIUfZ4TgegySfqTRRR3MXualeXeHP8AiYeKLb7b/pO/dv8AO+fdhDjOevQflRRRE0p9T1GiiipMgooooAKKKKACiiigAooooAwvE0ERtY5jEhlLhN+0btuGOM+me1FFFaROqn8KP//Z",
	    "token": "6e6d8708120a401aaf6709909cc49f9c"
	  }
	}
});

router.get('/vote/app/vote/voteVideo', function *(next) {
    this.body = {
	  "resultCode": "0",
	  "resultMessage": "success",
	}
});

// 开始服务并生成路由
app.use(cors({
    credentials:true,
    origin: 'http://localhost:4000'
})).use(router.routes()).use(router.allowedMethods());
app.listen(9000);